package com.chance.cc.crawler.development.command.trigger.domain.douban;

import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.development.command.trigger.CrawlerJobTriggerCommand;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;

/**
 * @Author Zhao.Hhuan
 * @Date Create in 2021/3/30 11:33
 * @Description
 *      豆瓣
 **/
public class DoubanScheduleTrigger {

    private static final String domainId = "douban";

    private static CrawlerJobTriggerCommand crawlerJobTriggerCommand =
            new CrawlerJobTriggerCommand("192.168.1.215",9599);

    public static void traceCrawlerScheduleTriggerInfo(String crawlerKey,String crawlerTriggerKey){
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerKey,
                crawlerTriggerKey,
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 4 * * ?",
                "豆瓣回溯7天，每天定时凌晨四点采集");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void simpleCrawlerScheduleTriggerInfo(String crawlerKey,String crawlerTriggerKey) {
        HttpPage httpPage = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerKey,
                crawlerTriggerKey,
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                  "豆瓣临时采集任务"
        );
        System.out.println("添加采集调度信息：" + httpPage.getRawText());
        System.out.println("triggerKey: " + crawlerTriggerKey);
    }

    public static void realtimeCrawlerScheduleTriggerInfo(String crawlerKey,String crawlerTriggerKey) {
        HttpPage httpPage = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerKey,
                crawlerTriggerKey,
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 0/2 * * ?",
                "豆瓣实时采集任务，每两个小时采集一次"
        );
        System.out.println("添加采集调度信息：" + httpPage.getRawText());
        System.out.println("triggerKey: " + crawlerTriggerKey);
    }
}
